﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Administration;

namespace AutocompleteDemo
{
    [System.Runtime.InteropServices.Guid("0DB24DDD-7456-4438-B3C0-87E3B07EBF33")]
    [SupportedServiceApplication("53C0AC5E-A58A-43E9-8389-4733BEF5277A", 
        "1.0.0.0", typeof(AutoCompletionServiceApplicationProxy))]
    public sealed class AutoCompletionServiceProxy : SPIisWebServiceProxy, IServiceProxyAdministration
    {
         // An empty public constructor required for serialization.
        public AutoCompletionServiceProxy() 
        {
        }

        internal AutoCompletionServiceProxy(SPFarm farm)
            : base(farm)
        {
        }

        #region IServiceProxyAdministration

        public Type[] GetProxyTypes()
        {
            return new Type[] { typeof(AutoCompletionServiceApplicationProxy) };
        }

        public SPPersistedTypeDescription GetProxyTypeDescription(
            Type serviceApplicationProxyType)
        {
            return new SPPersistedTypeDescription(
                "Auto Completion Web Service Proxy",
                "Connects to the Auto Completion Web Service.");
        }

        public SPServiceApplicationProxy CreateProxy(Type serviceApplicationProxyType, 
            string name, Uri serviceApplicationUri, SPServiceProvisioningContext provisioningContext)
        {
            if (serviceApplicationProxyType != typeof(AutoCompletionServiceApplicationProxy))
            {
                throw new NotSupportedException();
            }

            return new AutoCompletionServiceApplicationProxy(name, this, serviceApplicationUri);
        }

        #endregion
    }
}
